home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / security.zip / SECURITY.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-04  |  4KB  |  185 lines

  1. {
  2. * Written and compiled in turbo pascal by:
  3.   David Eisner
  4.   
  5.  
  6.    This program:
  7.  
  8.    - is for anyone's use
  9.  
  10.    - will die after three unsuccessful attempts at entry
  11.  
  12.    - will only accept one (1) system identifier  (always)
  13.                       one (1) user name          (current)
  14.                       one (1) password           (current)
  15.  
  16.      but can easily be modified to accept more
  17.  
  18.    - has default string arguments of 10
  19.      except for system identifier which is 15
  20.  
  21.    - * has no facility for dos shell protection and might
  22.      be circumvented by a ctrl-c / break before program
  23.      execution begins
  24.  
  25.      to help, turn break off in your autoexec.bat file
  26.      as a first line command, execute security, then turn
  27.      break on
  28.  
  29.    - is therefore intended as a first-step / demonstration
  30.      pascal security utility with window use 
  31.  
  32. }
  33.  
  34. program SECURITY(input,output);
  35. {$U-}
  36. {$C-}
  37.   type
  38.     res = record
  39.          ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
  40.           end;
  41.   var
  42.    x1, x2, y1, y2: integer;
  43.    tx,ty: integer;
  44.    d,i: integer;
  45.    access: boolean;
  46.    count: integer;
  47.    usr: string[10];
  48.    paswd: string[10];
  49.    who: string[15];
  50.    nam, pas: string[10];
  51.    r: res;
  52.    p1: text;
  53.   procedure delay;
  54.    begin
  55.      for i:= 1 to 31000 do
  56.       for d:= 1 to 2 do
  57.        begin end;
  58.    end;
  59.   procedure frame;
  60.    begin
  61.     x1:= 1;
  62.     x2:= 30;
  63.     y1:= 2;
  64.     y2:= 6;
  65.     clrscr;
  66.     gotoxy(x1+1,y1);
  67.     for tx:= x1+1 to x2-1 do
  68.      write(chr(196));
  69.     gotoxy(x1+1,y2);
  70.     for tx:= x1+1 to x2-1 do
  71.      write(chr(196));
  72.     gotoxy(x2,y1);
  73.     for ty:= y1+1 to y2-1 do
  74.      begin
  75.        gotoxy(x2,ty);
  76.        write(chr(179))
  77.      end;
  78.     gotoxy(x1,y1);
  79.     for ty:= y1+1 to y2-1 do
  80.      begin
  81.        gotoxy(x1,ty);
  82.        write(chr(179))
  83.      end;
  84.     gotoxy(x1,y1);
  85.     write(chr(218));
  86.     gotoxy(x2,y1);
  87.     write(chr(191));
  88.     gotoxy(x1,y2);
  89.     write(chr(192));
  90.     gotoxy(x2,y2);
  91.     write(chr(217));
  92.     gotoxy(x1+9,y1);
  93.     write(who);
  94.     gotoxy(x1+5,y2);
  95.     write('system ');
  96.     textcolor(15+16);
  97.     write('authorization');
  98.     textbackground(4);
  99.     gotoxy(x1+1,y1+1);
  100.     for i:= x1+1 to x2-1 do
  101.      write(chr(32));
  102.     window(x1+1,y1+1,x2-1,y2-1)
  103.    end;
  104.   procedure getuser;
  105.    begin
  106.      clrscr;
  107.      textcolor(15);
  108.      writeln;
  109.      write('user: ');
  110.      read(usr);
  111.      clrscr;
  112.      writeln;
  113.      write('password: ');
  114.      textcolor(4);
  115.      read(paswd);
  116.    end;
  117.  procedure verify;
  118.   begin
  119.     if (usr = nam) and (paswd = pas) then
  120.       access:= true;
  121.   end;
  122.  procedure result;
  123.   begin
  124.     clrscr;
  125.     if access = true then
  126.      begin
  127.        clrscr;
  128.        writeln;
  129.        textcolor(15);
  130.        write('access: ');
  131.        textcolor(15+16);
  132.        write('CONFIRMED');
  133.        textcolor(15);
  134.       end
  135.     else
  136.     begin
  137.       count:= count +1;
  138.       if count = 4 then
  139.        begin
  140.          clrscr;
  141.          textcolor(15);
  142.          gotoxy(10,2);
  143.          write('GOODBYE !');
  144.          inline($50/$53/$51/$52/$56/$57/$1E/$06/$FB);
  145.          r.di:= 1;
  146.          intr(1,r);
  147.          inline($07/$1F/$5F/$5E/$5A/$59/$5B/$58/$8B/$E5/$5D/$CF);
  148.          {termination}
  149.        end;
  150.       clrscr;
  151.       textcolor(15);
  152.       writeln;
  153.       write('access: ');
  154.       textcolor(15+16);
  155.       write('DENIED');
  156.       textcolor(15);
  157.       delay;
  158.       clrscr;
  159.       getuser;
  160.       verify;
  161.       result;
  162.      end
  163.     end;
  164.   begin{main}
  165.    assign(p1,'security.pwd');
  166.    reset(p1);
  167.    readln(p1,who);  { system identifier }
  168.    readln(p1,nam);  { the user }
  169.    readln(p1,pas);  { user's password }
  170.    close(p1);
  171.    access:= false;
  172.    count:= 1;
  173.    clrscr;
  174.    frame;
  175.    getuser;
  176.    verify;
  177.    result;
  178.    textmode;
  179.    window(1,1,80,25);
  180.    writeln;
  181.    writeln;
  182.    writeln;
  183.   end.{main}
  184.  
  185.